#include <QMessageBox>
#include <QGraphicsSceneMouseEvent>
#include <QWebFrame>
#include <QNetworkProxyFactory>

#include "hybridwebpage.h"
#include "graphicshybridview.h"
#include "hybridpluginmanager.h"
#include "hybridfw_global.h"

#if defined(Q_OS_SYMBIAN) && !defined(HAVE_NOKIAQTSDK)
#include "sym_iap_util.h"
#endif

GraphicsHybridView::GraphicsHybridView(QMainWindow *parentWindow,QGraphicsItem *parent, QString identifier) :
        QGraphicsWebView(parent)
{
#if defined(Q_OS_SYMBIAN) && !defined(HAVE_NOKIAQTSDK)
    qt_SetDefaultIap();
#endif	

	// Find the default proxy for http connections, use the first item
	QList<QNetworkProxy> list = QNetworkProxyFactory::systemProxyForQuery(QNetworkProxyQuery(QUrl("http://www.google.com/")));
	if (list.count() >= 1)
	{
		QNetworkProxy::setApplicationProxy(list.at(0));
	}

	m_hybridWebPage = new HybridWebPage(this);
	connect(m_hybridWebPage->mainFrame(), SIGNAL(contentsSizeChanged(QSize)),
			this, SIGNAL(contentsSizeChanged(QSize)));

	this->setPage(m_hybridWebPage);
	
	m_pluginManager = new HybridPluginManager(this, parentWindow,identifier);
	m_pluginManager->initFrame(page()->mainFrame());
}

HybridPluginManager *GraphicsHybridView::plugins()
{
	return m_pluginManager;
}

void GraphicsHybridView::enableLogging()
{
	m_hybridWebPage->enableLogging();
}
